/**
 * This file is part of 1genia trampoline
 * Copyright (C) 2007-2008 1genia (contact@1genia.com)
 *
 * This library is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; version 3 of the License. 
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details. 
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; see the file COPYING.TXT.  If not,
 * write to the Free Software Foundation, Inc., 51 Franklin Street,
 * Fifth Floor, Boston, MA 02110-1301, USA. 
 **/
package com.genia.toolbox.projects.toolbox_basics_project.web.gwt.form.bean.impl;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

import com.genia.toolbox.basics.exception.BundledException;
import com.genia.toolbox.projects.toolbox_basics_project.bean.PersistableApplicationParameter;
import com.genia.toolbox.web.gwt.form.client.validator.Validator;
import com.genia.toolbox.web.gwt.form.client.validator.impl.DoubleValidator;

/**
 * Implementation of
 * {@link com.genia.toolbox.projects.toolbox_basics_project.web.gwt.form.bean.FormParameterHandler}
 * for floats.
 */
public class DoubleFormParameterHandler
    extends DefaultFormParameterHandler
{

  /**
   * returns the {@link Set} of {@link Class} that this handler handle.
   * 
   * @return the {@link Set} of {@link Class} that this handler handle or
   *         <code>null</code> if this handler is the default one
   * @see com.genia.toolbox.projects.toolbox_basics_project.bean.PersistableApplicationParameterHandler#getHandlingClasses()
   */
  @SuppressWarnings("unchecked")
  @Override
  public Set<Class<?>> getHandlingClasses()
  {
    return new HashSet<Class<?>>(Arrays.asList(Float.class, Double.class));
  }



  /**
   * returns the {@link Validator} that check that values of the current
   * parameter.
   * 
   * @param applicationParameter
   *          the parameter to generate the {@link Validator} for
   * @return the {@link Validator} that check that values of the current
   *         parameter
   * @throws BundledException
   *           if an error occured
   */
  @Override
  public Validator addValidator(PersistableApplicationParameter<Object> applicationParameter)
      throws BundledException
  {
    return new DoubleValidator();
  }

}
